<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title></title>
<style type="text/css">

body{ background:#EEEEEE;margin:0; padding:0; font-family:"微软雅黑", Arial, Helvetica, sans-serif; }

a{ color:#006600; text-decoration:none;}

a:hover{color:#990000;}

.top{ margin:5px auto; color:#990000; text-align:center;}

.info select{ border:1px #993300 solid; background:#FFFFFF;}

.info{ margin:5px; text-align:center;}

.info #show{ color:#3399FF; }

.bottom{ text-align:right; font-size:12px; color:#CCCCCC; width:1000px;}

</style>

</head>

<body>
<link rel="stylesheet" href="__PUBLIC__/css/pintuer.css">
<link rel="stylesheet" href="__PUBLIC__/css/admin.css">
<script src="__PUBLIC__/js/jquery.js"></script>
<script src="__PUBLIC__/js/pintuer.js"></script>
</head>
<body>
<form method="post" action="" id="listform">
  <div class="panel admin-panel">
    <div class="panel-head"><strong class="icon-reorder"> 内容列表</strong> <a href="" style="float:right; display:none;">添加字段</a></div>
    <div class="padding border-bottom">
      <ul class="search" style="padding-left:10px;">
        <li>
          <input type="text" placeholder="请输入搜索关键字" id="keywords" class="input" style="width:250px; line-height:17px;display:inline-block" />
          <a href="javascript:void(0)" class="button border-main icon-search" id="sec">搜索</a></li>
        <script>
            function timetrans(date){
                var date = new Date(date*1000);//如果date为13位不需要乘1000
                var Y = date.getFullYear() + '-';
                var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
                var D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate()) + ' ';
                var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
                var m = (date.getMinutes() <10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
                var s = (date.getSeconds() <10 ? '0' + date.getSeconds() : date.getSeconds());
                return Y+M+D+h+m+s;
            }
            $("#sec").click(function(){
                var keyword = $("#keywords").val();
                $.ajax({
                    type:'POST',
                    dataType:'json',
                    url: '__CONTROLLER__/seachs',
                    data:{keyword:keyword},
                    success:function (data) {
                        $("#tbody").empty();
                        var tr='';
                        for(var i=0; i<data.length;i++){
                            var url = '<img src="__PUBLIC__/Upload/'+data[i].imagename+'" alt="" width="70" height="50" >'
                            var html4=timetrans(data[i].addtime)
                            var html6='<a class="button border-main" href="__MODULE__/News/update?id='+data[i].id+'"><span class="icon-edit"></span>修改</a><a class="button border-red" href="javascript:void(0)" onclick="del(id)"><span class="icon-trash-o"></span>删除</a>'
                            tr+='<tr><td style="text-align:center;padding-left:20px;">'+data[i].id+'</td><td>'+data[i].daoyu+'</td>' +
                                '<td>'+data[i].title+'</td><td>'+url+'</td> <td>'+data[i].operator+'</td><td>'+html4+'</td> <td><div class="button-group">'+html6+'</div></td> </tr>;'
                        }
                        $('#tbody').append(tr);//追加到你需要放在的位置
                    }
                });
            })
        </script>
      </ul>
    </div>
    <table class="table table-hover text-center">
      <tr>
        <th width="100" style="text-align:left; padding-left:20px;">ID</th>
        <th  width="500">导语</th>
        <th>标题</th>
        <th>图片</th>
        <th>操作员</th>
        <th width="10%">添加时间</th>
        <th width="210">操作</th>
      </tr>
      <tbody id="tbody">
      <foreach name="arr" item="v">
        <tr>
          <td>{$v.id}</td>
          <td>{$v.daoyu}</td>
          <td>{$v.title}</td>
          <td width="10%"><img src="__PUBLIC__/Upload/{$v.imagename}" alt="" width="70" height="50" /></td>
          <td>{$v.operator}</td>
          <td><?php echo date("Y-m-d H:i:s",$v["addtime"])?></td>
          <td><div class="button-group">
            <?php if($_SESSION['status']==1){?>
            <a class="button border-main" href="<?=U("News/update",array('id'=>$v['id']));?>"><span class="icon-edit"></span> 修改</a>
            <a class="button border-red" href="javascript:void(0)" onclick=" del(<?php echo $v['id']?>)"><span class="icon-trash-o"></span>删除</a>
            <?php }else{ ?>
            你无权操作
            <?php }?>
          </div></td>
        </tr>
        </foreach>
      </tbody>

      <td colspan="11"><div class="pagelist"> {$pageStr} </div></td>

    </table>
  </div>
</form>
<script type="text/javascript">



//单个删除
function del(id){
	var title = window.confirm('您确定要删除此条数据么？')
	if(title){
		$.ajax({
			type:'post',
			url:'__CONTROLLER__/del',
			data:{id:id},
			dataType:"json",
			success:function(){
				window.location.reload()
			}
		})
	}else{

	}}

</script>
</body>
</html>